home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2549 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: mail2news.demon.co.uk!hpl3sn03.cern.ch
  2. From: Dan Pop <danpop@mail.cern.ch>
  3. Newsgroups: comp.lang.c++,comp.lang.c
  4. Subject: Re: Hungarian notation
  5. Date: Thu, 18 Jan 1996 13:11:37 +0100
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <9601181211.AA03705@dxmint.cern.ch>
  8. References: <4dhkae$an9@blackice.winternet.com> <821890870snz@genesis.demon.co.uk> <30fd5306.3171520@nntp.ix.netcom.com>
  9. X-NNTP-Posting-Host: hpl3sn03.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11. X-Mail2News-Path: dxmint.cern.ch!hpl3sn03.cern.ch
  12.  
  13. miker3@ix.netcom.com (Mike Rubenstein) writes:
  14.  
  15. >There is one possibility that makes the cast to long double
  16. >potentially dangerous according to the standard.  There is no
  17. >guarantee in the standard that all possible values of an integral type
  18. >can be converted to long double.
  19.  
  20. Such a guarantee actually exists.  
  21.  
  22.     (ANSI classic) 3.2.1.5 Usual arithmetic conversions
  23.  
  24.     Many binary operators that expect operands of arithmetic type cause
  25.     conversions and yield result types in a similar way.  The purpose is
  26.     to yield a common type, which is also the type of the result.  This
  27.     pattern is called the usual arithmetic conversions: First, if either
  28.     operand has type long double, the other operand is converted to long
  29.     double.
  30.  
  31. The last statement (sort of) guarantees that any arithmetic type can be
  32. safely converted to long double, even if some information is lost in the
  33. conversion (I'm typing this text on a machine where both long and long
  34. double have the same size, hence some long values cannot be converted to
  35. long double without loss of precision).
  36.  
  37. Dan
  38. -- 
  39. Dan Pop
  40. CERN, CN Division
  41. Email: danpop@mail.cern.ch 
  42. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  43.